---
name: Quick Start
---

# Quick Start

Genql translates typed code into graphql queries, enabling you to get auto completion and validation for your graphql queries.

To use genql you first need to generate a sdk client

## Generate with the cli

First install the required package from npm

```bash
npm init -y
npm i -D @genql/cli # cli to generate the client code
npm i graphql # runtime dependencies
```

> `@genql/cli` is a dev dependency because it is only required to generate the client

Then run the genql command to generate the client inside a directory

```bash
genql --schema ./schema.graphql --output ./generated
# or using a graphql api url
genql --endpoint https://countries.trevorblades.com --output ./generated -H 'Authorization: Bearer myToken'
```

## Using the client

The generated files expose a function `createClient`, this creates a client you can use to send requests

```js
// example client generated with genql
const { createClient } = require('./generated')

const client = createClient({
    url: 'https://countries.trevorblades.com',
    headers: {
        'Some-Header': 'hello',
    },
})
client
    .query({
        countries: {
            name: true,
            code: true,
        },
    })
    .then(console.log)
```

Read more about the graphql client methods in the usage section